<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>小宅社区</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="{{ static('images/logo.ico') }}"/>
    <meta name="keywords" content="小宅社区">
    <meta name="description" content="小宅社区">
    {#  <link rel="stylesheet" href="../res/layui/css/layui.css">#}
    <link rel="stylesheet" href={{ static('js/layui/css/layui.css') }}>
    {#  <link rel="stylesheet" href="../res/css/global.css">#}
    <link rel="stylesheet" href={{ static('css/global.css') }}>
</head>
<body>

<div class="fly-header layui-bg-black">
    <div class="layui-container">
        <a class="fly-logo" href="/">
            {#            <img src="../res/images/logo.png" alt="layui">#}
            <img src={{ static('images/logo.png') }} alt="layui">
        </a>
        <ul class="layui-nav fly-nav layui-hide-xs">
            <li class="layui-nav-item layui-this">
                <a href="/"><i class="iconfont icon-jiaoliu"></i>交流</a>
            </li>
            <li class="layui-nav-item">
                <a href="/case/case"><i class="iconfont icon-iconmingxinganli"></i>案例</a>
            </li>
        </ul>

        <ul class="layui-nav fly-nav-user">
            {% if user.username %}
                <li class="layui-nav-item">
                    <a class="fly-nav-avatar" href="/user/index">
                        <cite class="layui-hide-xs">{{ user.username }}</cite>
                        <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：layui 作者"></i>
                        <i class="layui-badge fly-badge-vip layui-hide-xs">VIP{{ user.is_vip }}</i>
                        <img src="{{ user.images_url }}">
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="/user/set"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
                        <dd><a href="/user/index"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a>
                        </dd>
                        <dd><a href="/user/home?u={{ user.id }}"><i class="layui-icon"
                                                                    style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a>
                        </dd>
                        <hr style="margin: 5px 0;">
                        <dd><a href="/logout/" style="text-align: center;">退出</a></dd>
                    </dl>
                </li>
            {% else %}
                <li class="layui-nav-item">
                    <a class="iconfont icon-touxiang layui-hide-xs" href="/login"></a>
                </li>
                <li class="layui-nav-item">
                    <a href="/login">登入</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/reg">注册</a>
                </li>


            {% endif %}
        </ul>
    </div>
</div>

<div class="fly-panel fly-column">
    <div class="layui-container">
        <ul class="layui-clear">
            {% if num == 1 %}
                <li class="layui-hide-xs layui-this"><a href="">首页</a></li>
            {% else %}
                <li class=""><a href="/">首页</a></li>
            {% endif %}
            {% if num == "tw" %}
                <li class="layui-hide-xs layui-this"><a href="">提问</a></li>
            {% else %}
                <li><a href="/zy?are=tw">提问</a></li>
            {% endif %}
            {% if num == "fx" %}
                <li class="layui-hide-xs layui-this"><a href="">分享</a></li>
                <!--?    可以创造红点        <span class="layui-badge-dot"></span>-->
            {% else %}
                <li><a href="/zy?are=fx">分享</a></li>
            {% endif %}
            {% if num == "tl" %}
                <li class="layui-hide-xs layui-this"><a href="">讨论</a></li>
            {% else %}
                <li><a href="zy?are=tl">讨论</a></li>
            {% endif %}
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
            <!-- 用户登入后显示 -->
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a
                    href="/user/user_message">我发表的贴</a></li>
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="/user/collects">我收藏的贴</a>
            </li>
        </ul>

        <div class="fly-column-right layui-hide-xs">
            <span class="fly-search"><i class="layui-icon"></i></span>
            <a href="/user/add" class="layui-btn">发表新帖</a>
        </div>
        <div class="layui-hide-sm layui-show-xs-block"
             style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
            <a href="/user/add" class="layui-btn">发表新帖</a>
        </div>
    </div>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8">

            <div class="fly-panel" style="margin-bottom: 0;">

                <div class="fly-panel-title fly-filter">
                    <a class="layui-this">社区</a>
                    <span class="fly-filter-right layui-hide-xs">
                        {% if num == 1 %}
                            {% if sort == 'newest' %}
                                <a href="/?sort=newest" class="layui-this">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/?sort=heated">按热议</a>
                            {% elif sort == 'heated' %}
                                <a href="/?sort=newest">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/?sort=heated" class="layui-this">按热议</a>
                            {% else %}
                                <span class="fly-mid"></span>
                            {% endif %}
                        {% elif num == "tw" %}
                            {% if sort == 'newest' %}
                                <a href="/zy?are=tw&sort=newest" class="layui-this">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/zy?are=tw&sort=heated">按热议</a>
                            {% elif sort == 'heated' %}
                                <a href="/zy?are=tw&sort=newest">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/zy?are=tw&sort=heated" class="layui-this">按热议</a>
                            {% endif %}
                        {% elif num == "fz" %}
                            {% if sort == 'newest' %}
                                <a href="/zy?are=fz&sort=newest" class="layui-this">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/zy?are=fz&sort=heated">按热议</a>
                            {% elif sort == 'heated' %}
                                <a href="/zy?are=fz&sort=newest">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/zy?are=fz&sort=heated" class="layui-this">按热议</a>
                            {% endif %}
                        {% elif num == "tl" %}
                            {% if sort == 'newest' %}
                                <a href="/zy?are=tl&sort=newest" class="layui-this">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/zy?are=tl&sort=heated">按热议</a>
                            {% elif sort == 'heated' %}
                                <a href="/zy?are=tl&sort=newest">按最新</a>
                                <span class="fly-mid"></span>
                                <a href="/zy?are=tl&sort=heated" class="layui-this">按热议</a>
                            {% endif %}

                        {% endif %}
          </span>
                </div>

                <ul class="fly-list">
                    {% for sku in page_skus %}
                        <li>
                            <a href="/user/home?u={{ sku.user_id }}" class="fly-avatar">
                                <img src="{{ sku.user.images_url }}"
                                     alt="{{ sku.user.username }}">
                            </a>
                            <h2>
                                <a class="layui-badge">{{ sku.category.name }}</a>
                                <a href="jie/detail?u={{ sku.id }}">{{ sku.title }}</a>
                            </h2>
                            <div class="fly-list-info">
                                <a href="/user/home?u={{ sku.user_id }}" link>
                                    <cite>{{ sku.user.username }}</cite>


                                    {% if sku.user.is_vip != 0 %}
                                        <i class="layui-badge fly-badge-vip">VIP{{ sku.user.is_vip }}</i>
                                        <i class="iconfont icon-renzheng" title="认证信息：fly社区认证用户"></i>
                                    {% endif %}

                                </a>
                                <span>{{ sku.modify_time.strftime("%Y-%m-%d %H:%M") }}</span>

                                <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i
                                        class="iconfont icon-kiss"></i> {{ sku.award }}</span>
                                <!--<span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>-->
                                <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> {{ sku.comment_num }}
              </span>
                            </div>
                            <div class="fly-list-badge">
                                <!--<span class="layui-badge layui-bg-red">精帖</span>-->
                            </div>
                        </li>
                    {% endfor %}


                </ul>


                <div style="text-align: center">
                    <div style="border-top: 1px dotted #e2e2e2; text-align: center;">

                        <div class="laypage-main">
                            {% if num == 1 %}
                                {% if page_num > 1 %}
                                    <a href="?page=1" class="laypage-last" title="首页">首页</a>
                                    <a href="/?page={{ page_num - 1 }}" class="laypage-prev">上一页</a>
                                {% endif %}
                                {% if page_num - 3 > 1 %}
                                    <span>…</span>
                                {% endif %}
                                {% if page_num > 1 %}
                                    {% if page_num - 1 <= total_page %}
                                        <a href="?page={{ page_num - 1 }}">{{ page_num - 1 }}</a>
                                    {% endif %}
                                {% endif %}
                                <span class="laypage-curr">{{ page_num }}</span>
                                {% if page_num + 1 <= total_page %}
                                    <a href="?page={{ page_num + 1 }}">{{ page_num + 1 }}</a>
                                {% endif %}
                                {% if page_num + 2 <= total_page %}
                                    <a href="?page={{ page_num + 2 }}">{{ page_num + 2 }}</a>
                                {% endif %}
                                {% if page_num + 3 <= total_page - 1 %}
                                    <span>…</span>
                                {% endif %}

                                {% if page_num < total_page %}
                                    <a href="?page={{ total_page }}" class="laypage-last" title="尾页">尾页</a>
                                    <a href="?page={{ page_num + 1 }}" class="laypage-next">下一页</a>
                                {% endif %}

                            {% elif num == "tw" %}

                                {% if page_num > 1 %}}
                                    <a href="/zy?are=tw&page=1" class="laypage-last" title="首页">首页</a>
                                    <a href="/zy?are=tw&page={{ page_num - 1 }}" class="laypage-prev">上一页</a>
                                {% endif %}
                                {% if page_num - 3 > 1 %}
                                    <span>…</span>
                                {% endif %}
                                {% if page_num > 1 %}
                                    {% if page_num - 1 <= total_page %}
                                        <a href="/zy?are=tw&page={{ page_num - 1 }}">{{ page_num - 1 }}</a>
                                    {% endif %}
                                {% endif %}
                                <span class="laypage-curr">{{ page_num }}</span>
                                {% if page_num + 1 <= total_page %}
                                    <a href="/zy?are=tw&page={{ page_num + 1 }}">{{ page_num + 1 }}</a>
                                {% endif %}
                                {% if page_num + 2 <= total_page %}
                                    <a href="/zy?are=tw&page={{ page_num + 2 }}">{{ page_num + 2 }}</a>
                                {% endif %}
                                {% if page_num + 3 <= total_page - 1 %}
                                    <span>…</span>
                                {% endif %}

                                {% if page_num < total_page %}
                                    <a href="/zy?are=tw&page={{ total_page }}" class="laypage-last" title="尾页">尾页</a>
                                    <a href="/zy?are=tw&page={{ page_num + 1 }}" class="laypage-next">下一页</a>
                                {% endif %}


                            {% elif num == "fx" %}
                                {% if page_num > 1 %}}
                                    <a href="/zy?are=fx&page=1" class="laypage-last" title="首页">首页</a>
                                    <a href="/zy?are=fx&page={{ page_num - 1 }}" class="laypage-prev">上一页</a>
                                {% endif %}
                                {% if page_num - 3 > 1 %}
                                    <span>…</span>
                                {% endif %}
                                {% if page_num > 1 %}
                                    {% if page_num - 1 <= total_page %}
                                        <a href="/zy?are=fx&page={{ page_num - 1 }}">{{ page_num - 1 }}</a>
                                    {% endif %}
                                {% endif %}
                                <span class="laypage-curr">{{ page_num }}</span>
                                {% if page_num + 1 <= total_page %}
                                    <a href="/zy?are=fx&page={{ page_num + 1 }}">{{ page_num + 1 }}</a>
                                {% endif %}
                                {% if page_num + 2 <= total_page %}
                                    <a href="/zy?are=fx&page={{ page_num + 2 }}">{{ page_num + 2 }}</a>
                                {% endif %}
                                {% if page_num + 3 <= total_page - 1 %}
                                    <span>…</span>
                                {% endif %}

                                {% if page_num < total_page %}
                                    <a href="/zy?are=fx&page={{ total_page }}" class="laypage-last" title="尾页">尾页</a>
                                    <a href="/zy?are=fx&page={{ page_num + 1 }}" class="laypage-next">下一页</a>
                                {% endif %}

                            {% elif num == "tl" %}
                                {% if page_num > 1 %}}
                                    <a href="/zy?are=tl&page=1" class="laypage-last" title="首页">首页</a>
                                    <a href="/zy?are=tl&page={{ page_num - 1 }}" class="laypage-prev">上一页</a>
                                {% endif %}
                                {% if page_num - 3 > 1 %}
                                    <span>…</span>
                                {% endif %}
                                {% if page_num > 1 %}
                                    {% if page_num - 1 <= total_page %}
                                        <a href="/zy?are=tl&page={{ page_num - 1 }}">{{ page_num - 1 }}</a>
                                    {% endif %}
                                {% endif %}
                                <span class="laypage-curr">{{ page_num }}</span>
                                {% if page_num + 1 <= total_page %}
                                    <a href="/zy?are=tl&page={{ page_num + 1 }}">{{ page_num + 1 }}</a>
                                {% endif %}
                                {% if page_num + 2 <= total_page %}
                                    <a href="/zy?are=tl&page={{ page_num + 2 }}">{{ page_num + 2 }}</a>
                                {% endif %}
                                {% if page_num + 3 <= total_page - 1 %}
                                    <span>…</span>
                                {% endif %}

                                {% if page_num < total_page %}
                                    <a href="/zy?are=tl&page={{ total_page }}" class="laypage-last" title="尾页">尾页</a>
                                    <a href="/zy?are=tl&page={{ page_num + 1 }}" class="laypage-next">下一页</a>
                                {% endif %}
                            {% elif num == "search" %}
                                {% if page_num > 1 %}}
                                    <a href="/search?q={{ are }}&page=1" class="laypage-last" title="首页">首页</a>
                                    <a href="/search?q={{ are }}&page={{ page_num - 1 }}" class="laypage-prev">上一页</a>
                                {% endif %}
                                {% if page_num - 3 > 1 %}
                                    <span>…</span>
                                {% endif %}
                                {% if page_num > 1 %}
                                    {% if page_num - 1 <= total_page %}
                                        <a href="/search?q={{ are }}&page={{ page_num - 1 }}">{{ page_num - 1 }}</a>
                                    {% endif %}
                                {% endif %}
                                <span class="laypage-curr">{{ page_num }}</span>
                                {% if page_num + 1 <= total_page %}
                                    <a href="/search?q={{ are }}&page={{ page_num + 1 }}">{{ page_num + 1 }}</a>
                                {% endif %}
                                {% if page_num + 2 <= total_page %}
                                    <a href="/search?q={{ are }}&page={{ page_num + 2 }}">{{ page_num + 2 }}</a>
                                {% endif %}
                                {% if page_num + 3 <= total_page - 1 %}
                                    <span>…</span>
                                {% endif %}

                                {% if page_num < total_page %}
                                    <a href="/search?q={{ are }}&page={{ total_page }}" class="laypage-last"
                                       title="尾页">尾页</a>
                                    <a href="/search?q={{ are }}&page={{ page_num + 1 }}" class="laypage-next">下一页</a>
                                {% endif %}
                            {% endif %}
                        </div>
                    </div>

                </div>

            </div>
        </div>
        <div class="layui-col-md4">

            <div class="fly-panel">
                <h3 class="fly-panel-title">温馨通道</h3>
                <ul class="fly-panel-main fly-list-static">
                    <li>
                        <a href="http://fly.layui.com/jie/4281/" target="_blank">layui 的 GitHub 及 Gitee (码云)
                            仓库，欢迎Star</a>
                    </li>
                    <li>
                        <a href="http://fly.layui.com/jie/5366/" target="_blank">
                            layui 常见问题的处理和实用干货集锦
                        </a>
                    </li>
                    <li>
                        <a href="http://fly.layui.com/jie/4281/" target="_blank">layui 的 GitHub 及 Gitee (码云)
                            仓库，欢迎Star</a>
                    </li>
                    <li>
                        <a href="http://fly.layui.com/jie/5366/" target="_blank">
                            layui 常见问题的处理和实用干货集锦
                        </a>
                    </li>
                    <li>
                        <a href="http://fly.layui.com/jie/4281/" target="_blank">layui 的 GitHub 及 Gitee (码云)
                            仓库，欢迎Star</a>
                    </li>
                </ul>
            </div>


            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">本周热议</dt>
                {% for i in new %}
                    <dd>
                        <a href="jie/detail?u={{ i.id }}">{{ i.title }}</a>
                        <span><i class="iconfont icon-pinglun1"></i> {{ i.comment_num }}</span>
                    </dd>
                {% endfor %}
                <dd>
                    <a href="jie/detail.html">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>

                <!-- 无数据时 -->
                <!--
                <div class="fly-none">没有相关数据</div>
                -->
            </dl>

            <div class="fly-panel">
                <div class="fly-panel-title">
                    这里可作为广告区域
                </div>
                <div class="fly-panel-main">
                    <a href="http://layim.layui.com/?from=fly" target="_blank" class="fly-zanzhu"
                       time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">LayIM 3.0 - layui 旗舰之作</a>
                </div>
            </div>

            <div class="fly-panel fly-link">
                <h3 class="fly-panel-title">友情链接</h3>
                <dl class="fly-panel-main">
                    <dd><a href="http://www.layui.com/" target="_blank">layui</a>
                    <dd>
                    <dd><a href="http://layim.layui.com/" target="_blank">WebIM</a>
                    <dd>
                    <dd><a href="http://layer.layui.com/" target="_blank">layer</a>
                    <dd>
                    <dd><a href="http://www.layui.com/laydate/" target="_blank">layDate</a>
                    <dd>
                    <dd>
                        <a href="mailto:1060377319@qq.com?subject=%E7%94%B3%E8%AF%B7Fly%E7%A4%BE%E5%8C%BA%E5%8F%8B%E9%93%BE"
                           class="fly-link">申请友链</a>
                    <dd>
                </dl>
            </div>

        </div>
    </div>
</div>

<div class="fly-footer">
    <p><a href="#">小宅论坛</a> 2019 &copy; <a href="#">小宅娱乐出品</a>皖ICP备19010957号-1</p>
</div>

<script src={{ static('js/layui/layui.js') }}></script>
{#<script src="../res/layui/layui.js"></script>#}
<script>

    layui.cache.page = '';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '../res/images/avatar/00.jpg'
        , experience: 83
        , sex: '男'
    };

    layui.config({
        version: "3.0.0"
        , base: '../static/res/mods/' //这里实际使用时，建议改成绝对路径
    }).extend({
        fly: 'index'
    }).use('fly');

    layui.use('layer');

    $(function () {

        hasUser();

    });

    function hasUser() {

        let jwt = getJwtToken();
        if (jwt) {
            $.ajax({
                type: "get",
                url: HOST_URL + "user/getUser",
                dataType: "json",
                headers: createAuthorizationTokenHeader(),
                success: function (data) {
                    console.log(data);
                    if (data) {
                        let appendVal = `
                            <li class="layui-nav-item">
                              <a class="fly-nav-avatar" href="javascript:;">
                                <cite class="layui-hide-xs">${data.username}</cite>
<!--                                <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：layui 作者"></i>-->
                                <i class="layui-badge fly-badge-vip layui-hide-xs">VIP${data.level}</i>
                                <img src="${data.picture}">
                              </a>
                              <dl class="layui-nav-child">
                                <dd><a href="user/set"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
                                <dd><a href="user/index"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
                                <dd><a href="user/home?u={{user.id}}"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
                                <hr style="margin: 5px 0;">
                                <dd><a href="javascript:logout();" style="text-align: center;">退出</a></dd>
                              </dl>
                            </li>
                        `;

                        $("#ul_user").html(appendVal);
                    }
                }
            })
        }
    }

    /**
     * 注销
     */
    function logout() {
        layer.confirm("真的要注销吗?", () => {

            removeJwtToken();
            layer.msg("注销成功", {time: 1000}, function () {
                location.reload();
            });
        })
    }

</script>

<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cspan id='cnzz_stat_icon_30088308'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "w.cnzz.com/c.php%3Fid%3D30088308' type='text/javascript'%3E%3C/script%3E"));</script>

</body>
</html>